package com.krtech.wecard.module.pub.service.impl;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.util.StrUtil;
import cn.hutool.json.JSONUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.krtech.wecard.framework.exception.BusinessException;
import com.krtech.wecard.framework.utils.LoginUtil;
import com.krtech.wecard.module.pub.dto.ApplicationEnums;
import com.krtech.wecard.module.pub.dto.CardInfoVo;
import com.krtech.wecard.module.pub.dto.ClassificationInfoVo;
import com.krtech.wecard.module.pub.entity.*;
import com.krtech.wecard.module.pub.service.*;
import com.krtech.wecard.module.sys.entity.*;
import com.krtech.wecard.module.sys.enums.StatisticalMainEnums;
import com.krtech.wecard.module.sys.service.IdentityInfoService;
import com.krtech.wecard.module.sys.service.OrcodeFreezeListService;
import com.krtech.wecard.module.sys.service.StatisticalMainService;
import com.krtech.wecard.module.sys.service.SysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import java.util.stream.Collectors;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.krtech.wecard.module.pub.mapper.CardInfoMapper;
import org.springframework.transaction.annotation.Transactional;

/**
 * 卡管理
 */
@Service
public class CardInfoServiceImpl extends ServiceImpl<CardInfoMapper, CardInfo> implements CardInfoService {

    @Override
    public int updateBatch(List<CardInfo> list) {
        return baseMapper.updateBatch(list);
    }

    @Override
    public int batchInsert(List<CardInfo> list) {
        return baseMapper.batchInsert(list);
    }

    @Autowired
    private ClassificationInfoService classificationInfoService;

    @Autowired
    private ClassificationApplicationInfoService classificationApplicationInfoService;

    @Autowired
    private ApplicationManagementService applicationManagementService;

    @Autowired
    private CardIdentityRelationInfoService cardIdentityRelationInfoService;

    @Autowired
    private IdentityInfoService identityInfoService;

    @Autowired
    private SysUserService sysUserService;

    @Autowired
    private CardInfoUserService cardInfoUserService;

    @Autowired
    private OrcodeFreezeListService freezeListService;

    @Autowired
    private StatisticalMainService statisticalMainService;

    /**
     * 新增卡
     * 包含卡信息和身份对应
     *
     * @param cardInfoVo
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public CardInfoVo add(CardInfoVo cardInfoVo) {
        SysUser userInfo = LoginUtil.getUserInfo();

        List<IdentityInfo> identityInfoList = cardInfoVo.getIdentityInfoList();

        //验证身份是否合法
        for (IdentityInfo identityInfo : identityInfoList) {
            if (identityInfo.getId() == null) {
                throw new BusinessException("身份id为必填参数，不能为空");
            }
            IdentityInfo identityInfoServiceById = identityInfoService.getById(identityInfo.getId());

            if (identityInfoServiceById == null) {
                throw new BusinessException("给定身份id不正确，请检查");
            }
        }

        List<Integer> identityIdList = identityInfoList.stream().map(IdentityInfo::getId).collect(Collectors.toList());
        identityInfoList = identityInfoService.list(new QueryWrapper<IdentityInfo>().in(IdentityInfo.COL_ID, identityIdList));

        cardInfoVo.setIdentityStr(JSONUtil.toJsonStr(identityInfoList));
        //保存卡信息
        this.save(cardInfoVo);

        //保存卡和身份关联信息
        List<CardIdentityRelationInfo> cardIdentityRelationInfoList = identityInfoList.stream().map(identityInfo -> {
            CardIdentityRelationInfo cardIdentityRelationInfo = new CardIdentityRelationInfo();
            cardIdentityRelationInfo.setCreatedBy(userInfo.getUserId().toString());
            cardIdentityRelationInfo.setCreatedTime(new Date());
            cardIdentityRelationInfo.setCardId(cardInfoVo.getId());
            cardIdentityRelationInfo.setIdentityId(identityInfo.getId());
            cardIdentityRelationInfo.setIdentityCode(identityInfo.getCode());
            return cardIdentityRelationInfo;
        }).collect(Collectors.toList());
        cardIdentityRelationInfoService.saveBatch(cardIdentityRelationInfoList);


        //获取分类信息，保存分类信息
        List<ClassificationInfoVo> classificationInfoVoList = cardInfoVo.getClassificationInfoVoList();

        for (ClassificationInfoVo classificationInfoVo : classificationInfoVoList) {
            //保存一个分类信息，并且保存下属应用的关联
            classificationInfoVo.setFkPubCardInfoId(cardInfoVo.getId());
            classificationInfoVo.setCreatedBy(userInfo.getUserId().toString());
            classificationInfoVo.setCreatedTime(new Date());
            classificationInfoService.save(classificationInfoVo);

            //应用list
            List<ApplicationManagement> applicationManagementList = classificationInfoVo.getApplicationManagementList();

            for (ApplicationManagement applicationManagement : applicationManagementList) {
                //判断应用是否填写了id
                if (applicationManagement.getId() == null) {
                    throw new BusinessException("应用id不能为空");
                }
                applicationManagement = applicationManagementService.getById(applicationManagement.getId());

                //应用管理list
                ClassificationApplicationInfo classificationApplicationInfo = new ClassificationApplicationInfo();
                classificationApplicationInfo.setCreatedBy(userInfo.getUserId().toString());
                classificationApplicationInfo.setCreatedTime(new Date());
                classificationApplicationInfo.setFkClassificationId(classificationInfoVo.getId());
                classificationApplicationInfo.setFkApplicationId(applicationManagement.getId());
                classificationApplicationInfoService.save(classificationApplicationInfo);
            }

        }

        return this.getCardInfoById(cardInfoVo.getId());
    }

    /**
     * 改
     * 改的方式，是将下属的所有删除之后，再重新添加
     *
     * @param cardInfoVo
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public CardInfoVo updateByCardInfoVo(CardInfoVo cardInfoVo) {
        SysUser userInfo = LoginUtil.getUserInfo();
        if (cardInfoVo.getId() == null) {
            throw new BusinessException("更新时卡id必填，不能为空");
        }
        CardInfo info = this.getById(cardInfoVo.getId());
        if (info == null) {
            throw new BusinessException("没有id对应数据，不能更新");
        }

        //更新之前判断是否更新身份，如果更新身份，这张卡有人持有这个身份了，就不能修改了
        List<IdentityInfo> identityInfoList = cardInfoVo.getIdentityInfoList();
        if (identityInfoList.size() > 0) {
            int count = cardInfoUserService.count(new QueryWrapper<CardInfoUser>()
                    .eq(CardInfoUser.COL_CARD_ID, cardInfoVo.getId()));

            //查询身份list
            List<CardIdentityRelationInfo> cardIdentityRelationInfoList = cardIdentityRelationInfoService.list(new QueryWrapper<CardIdentityRelationInfo>()
                    .eq(CardIdentityRelationInfo.COL_CARD_ID, cardInfoVo.getId()));

            List<Integer> campareA = identityInfoList.stream().map(IdentityInfo::getId).collect(Collectors.toList());
            List<Integer> campareB = cardIdentityRelationInfoList.stream().map(CardIdentityRelationInfo::getIdentityId).collect(Collectors.toList());

            if (count > 0 && !campareA.equals(campareB)) {
                throw new BusinessException("该身份已经有用户，不能修改身份");
            }
        }


        //更新卡信息
        this.updateById(cardInfoVo);

        //删除原油的应用和原有的分类
        //根据cardid查询分类
        List<ClassificationInfo> classificationInfoList = classificationInfoService.list(new QueryWrapper<ClassificationInfo>()
                .eq(ClassificationInfo.COL_FK_PUB_CARD_INFO_ID, cardInfoVo.getId()));
        for (ClassificationInfo classificationInfo : classificationInfoList) {
            //根据分类id查询应用
            List<ClassificationApplicationInfo> classificationApplicationInfoList = classificationApplicationInfoService.list(new QueryWrapper<ClassificationApplicationInfo>()
                    .eq(ClassificationApplicationInfo.COL_FK_CLASSIFICATION_ID, classificationInfo.getId()));

            if (classificationApplicationInfoList.size() > 0){
                List<Integer> classificationAndApplicationIdList = classificationApplicationInfoList.stream()
                        .map(ClassificationApplicationInfo::getId).collect(Collectors.toList());

                classificationApplicationInfoService.remove(new QueryWrapper<ClassificationApplicationInfo>()
                        .in(ClassificationApplicationInfo.COL_ID, classificationAndApplicationIdList));
            }

            classificationInfoService.removeById(classificationInfo.getId());
        }

        //删除身份信息，并重新添加
        cardIdentityRelationInfoService.remove(new QueryWrapper<CardIdentityRelationInfo>()
                .eq(CardIdentityRelationInfo.COL_CARD_ID, cardInfoVo.getId()));


        //验证身份是否合法
        for (IdentityInfo identityInfo : identityInfoList) {
            if (identityInfo.getId() == null) {
                throw new BusinessException("身份id为必填参数，不能为空");
            }
            IdentityInfo identityInfoServiceById = identityInfoService.getById(identityInfo.getId());

            if (identityInfoServiceById == null) {
                throw new BusinessException("给定身份id不正确，请检查");
            }
        }

        List<Integer> identityIdList = identityInfoList.stream().map(IdentityInfo::getId).collect(Collectors.toList());
        identityInfoList = identityInfoService.list(new QueryWrapper<IdentityInfo>().in(IdentityInfo.COL_ID, identityIdList));

        //保存卡和身份关联信息
        List<CardIdentityRelationInfo> cardIdentityRelationInfoList = identityInfoList.stream().map(identityInfo -> {
            CardIdentityRelationInfo cardIdentityRelationInfo = new CardIdentityRelationInfo();
            cardIdentityRelationInfo.setCreatedBy(userInfo.getUserId().toString());
            cardIdentityRelationInfo.setCreatedTime(new Date());
            cardIdentityRelationInfo.setCardId(cardInfoVo.getId());
            cardIdentityRelationInfo.setIdentityId(identityInfo.getId());
            cardIdentityRelationInfo.setIdentityCode(identityInfo.getCode());
            return cardIdentityRelationInfo;
        }).collect(Collectors.toList());
        cardIdentityRelationInfoService.saveBatch(cardIdentityRelationInfoList);


        //获取分类信息，保存分类信息
        List<ClassificationInfoVo> classificationInfoVoList = cardInfoVo.getClassificationInfoVoList();

        for (ClassificationInfoVo classificationInfoVo : classificationInfoVoList) {
            //保存一个分类信息，并且保存下属应用的关联
            classificationInfoVo.setFkPubCardInfoId(cardInfoVo.getId());
            classificationInfoVo.setCreatedBy(userInfo.getUserId().toString());
            classificationInfoVo.setCreatedTime(new Date());
            classificationInfoService.save(classificationInfoVo);

            //应用list
            List<ApplicationManagement> applicationManagementList = classificationInfoVo.getApplicationManagementList();

            if (applicationManagementList != null && applicationManagementList.size() > 0){
                for (ApplicationManagement applicationManagement : applicationManagementList) {
                    //应用管理list
                    ClassificationApplicationInfo classificationApplicationInfo = new ClassificationApplicationInfo();
                    classificationApplicationInfo.setCreatedBy(userInfo.getUserId().toString());
                    classificationApplicationInfo.setCreatedTime(new Date());
                    classificationApplicationInfo.setFkClassificationId(classificationInfoVo.getId());
                    classificationApplicationInfo.setFkApplicationId(applicationManagement.getId());
                    classificationApplicationInfoService.save(classificationApplicationInfo);
                }
            }



        }

        return this.getCardInfoById(cardInfoVo.getId());
    }

    @Transactional(rollbackFor = Exception.class)
    @Override
    public Boolean delete(Integer id) {
        CardInfo cardInfo = this.getById(id);
        //删除原油的应用和原有的分类
        //根据cardid查询分类
        List<ClassificationInfo> classificationInfoList = classificationInfoService.list(new QueryWrapper<ClassificationInfo>()
                .eq(ClassificationInfo.COL_FK_PUB_CARD_INFO_ID, cardInfo.getId()));
        for (ClassificationInfo classificationInfo : classificationInfoList) {
            //根据分类id查询应用
            List<ClassificationApplicationInfo> classificationApplicationInfoList = classificationApplicationInfoService.list(new QueryWrapper<ClassificationApplicationInfo>()
                    .eq(ClassificationApplicationInfo.COL_FK_CLASSIFICATION_ID, classificationInfo.getId()));

            List<Integer> classificationAndApplicationIdList = classificationApplicationInfoList.stream()
                    .map(ClassificationApplicationInfo::getId).collect(Collectors.toList());

            classificationApplicationInfoService.remove(new QueryWrapper<ClassificationApplicationInfo>()
                    .in(ClassificationApplicationInfo.COL_ID, classificationAndApplicationIdList));

            classificationInfoService.removeById(classificationInfo.getId());

            cardIdentityRelationInfoService.remove(new QueryWrapper<CardIdentityRelationInfo>().eq(CardIdentityRelationInfo.COL_CARD_ID,id));
        }

        this.removeById(id);
        return true;
    }

    /**
     * 根据cardInfoId查询下属所有信息
     *
     * @param id
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public CardInfoVo getCardInfoById(Integer id) {
        SysUser userInfo = LoginUtil.getUserInfo();
        CardInfo cardInfo = this.getById(id);
        if (cardInfo == null) {
            return null;
        }
        //构造返回对象
        CardInfoVo cardInfoVo = new CardInfoVo();
        BeanUtil.copyProperties(cardInfo, cardInfoVo);

        //根据cardId查询分类
        List<ClassificationInfo> classificationInfoList = classificationInfoService.list(new QueryWrapper<ClassificationInfo>()
                .eq(ClassificationInfo.COL_FK_PUB_CARD_INFO_ID, cardInfoVo.getId()));

        List<ClassificationInfoVo> classificationInfoVoList = classificationInfoList.stream().map(classificationInfo -> {
            ClassificationInfoVo classificationInfoVo = new ClassificationInfoVo();
            BeanUtil.copyProperties(classificationInfo, classificationInfoVo);

            //根据分类查询应用
            List<ClassificationApplicationInfo> classificationApplicationInfoList = classificationApplicationInfoService.list(new QueryWrapper<ClassificationApplicationInfo>()
                    .eq(ClassificationApplicationInfo.COL_FK_CLASSIFICATION_ID, classificationInfoVo.getId()));

            if (classificationApplicationInfoList.size() > 0){
                //根据链接表，查询应用的信息

                List<ApplicationManagement> applicationManagementList =  new ArrayList<>();

                for (ClassificationApplicationInfo classificationApplicationInfo:classificationApplicationInfoList){
                    ApplicationManagement oneApplication = applicationManagementService
                            .getOne(new QueryWrapper<ApplicationManagement>()
                            .eq(ApplicationManagement.COL_STATUS, ApplicationEnums.APPLICATION_OPEN)
                                    .eq(ApplicationManagement.COL_ID, classificationApplicationInfo.getFkApplicationId()));

                    if (oneApplication == null){
                        continue;
                    }

                    // 判断当前用户是否可用这个应用，应用包含的部门以及人是否有当前用户
                    if (StrUtil.isEmpty(oneApplication.getAllowDeptList()) && StrUtil.isEmpty(oneApplication.getAllowUserList())){
                        continue;
                    }

                    if (StrUtil.isNotEmpty(oneApplication.getAllowDeptList())){
                        List<SysDept> deptList = JSONUtil.toList(oneApplication.getAllowDeptList(), SysDept.class);
                        if (deptList.size() > 0){
                            List<String> DeptCodeList = deptList.stream().map(SysDept::getCode).collect(Collectors.toList());
                            if (DeptCodeList != null && DeptCodeList.size() > 0){
                                List<String> deptCodeListAndSon = sysUserService.getDeptAndSonAsListByDeptCodeList(DeptCodeList);
                                if (deptCodeListAndSon.size() > 0 && deptCodeListAndSon.contains(userInfo.getDeptCode())){
                                    applicationManagementList.add(oneApplication);
                                    continue;
                                }
                            }
                        }

                    }

                    if (StrUtil.isNotEmpty(oneApplication.getAllowUserList())){
                        List<SysUser> sysUserList = JSONUtil.toList(oneApplication.getAllowUserList(), SysUser.class);
                        if (sysUserList.size() > 0){
                            List<String> userCodeList = sysUserList.stream().map(SysUser::getUserCode).collect(Collectors.toList());
                            if (userCodeList.size() > 0 && userCodeList.contains(userInfo.getUserCode())){
                                applicationManagementList.add(oneApplication);
                                continue;
                            }
                        }
                    }

//                    applicationManagementList.add(oneApplication);
                }


                classificationInfoVo.setApplicationManagementList(applicationManagementList);
            }


            return classificationInfoVo;
        }).collect(Collectors.toList());


        cardInfoVo.setClassificationInfoVoList(classificationInfoVoList);

        //查询身份list
        List<CardIdentityRelationInfo> cardIdentityRelationInfoList = cardIdentityRelationInfoService.list(new QueryWrapper<CardIdentityRelationInfo>()
                .eq(CardIdentityRelationInfo.COL_CARD_ID, cardInfoVo.getId()));

        List<Integer> identityIdList = cardIdentityRelationInfoList.stream().map(CardIdentityRelationInfo::getIdentityId).collect(Collectors.toList());
        List<IdentityInfo> identityInfoList = identityInfoService.list(new QueryWrapper<IdentityInfo>().in(IdentityInfo.COL_ID, identityIdList));

        cardInfoVo.setIdentityInfoList(identityInfoList);

        //判断当前人二维码是否被冻结
        OrcodeFreezeList freezeList = freezeListService.getOne(new QueryWrapper<OrcodeFreezeList>().eq(OrcodeFreezeList.COL_CODE, userInfo.getUserCode()));
        // 判断解冻时间
        if (freezeList != null){
            Date date = new Date();
            if (DateUtil.compare(date,freezeList.getUnfreezeTime()) < 0){
                cardInfoVo.setElectronicShow(0);
            }
        }

        return cardInfoVo;
    }


    /**
     * 根据cardInfoId查询下属所有信息
     *
     * @param id
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public CardInfoVo getManageById(Integer id) {
        SysUser userInfo = LoginUtil.getUserInfo();
        CardInfo cardInfo = this.getById(id);
        if (cardInfo == null) {
            return null;
        }
        //构造返回对象
        CardInfoVo cardInfoVo = new CardInfoVo();
        BeanUtil.copyProperties(cardInfo, cardInfoVo);

        //根据cardId查询分类
        List<ClassificationInfo> classificationInfoList = classificationInfoService.list(new QueryWrapper<ClassificationInfo>()
                .eq(ClassificationInfo.COL_FK_PUB_CARD_INFO_ID, cardInfoVo.getId()));

        List<ClassificationInfoVo> classificationInfoVoList = classificationInfoList.stream().map(classificationInfo -> {
            ClassificationInfoVo classificationInfoVo = new ClassificationInfoVo();
            BeanUtil.copyProperties(classificationInfo, classificationInfoVo);

            //根据分类查询应用
            List<ClassificationApplicationInfo> classificationApplicationInfoList = classificationApplicationInfoService.list(new QueryWrapper<ClassificationApplicationInfo>()
                    .eq(ClassificationApplicationInfo.COL_FK_CLASSIFICATION_ID, classificationInfoVo.getId()));

            if (classificationApplicationInfoList.size() > 0){
                //根据链接表，查询应用的信息

                List<ApplicationManagement> applicationManagementList =  new ArrayList<>();

                for (ClassificationApplicationInfo classificationApplicationInfo:classificationApplicationInfoList){
                    ApplicationManagement oneApplication = applicationManagementService
                            .getOne(new QueryWrapper<ApplicationManagement>()
                                    .eq(ApplicationManagement.COL_STATUS, ApplicationEnums.APPLICATION_OPEN)
                                    .eq(ApplicationManagement.COL_ID, classificationApplicationInfo.getFkApplicationId()));
                    if (oneApplication != null){
                        applicationManagementList.add(oneApplication);
                    }
                }


                classificationInfoVo.setApplicationManagementList(applicationManagementList);
            }


            return classificationInfoVo;
        }).collect(Collectors.toList());


        cardInfoVo.setClassificationInfoVoList(classificationInfoVoList);

        //查询身份list
        List<CardIdentityRelationInfo> cardIdentityRelationInfoList = cardIdentityRelationInfoService.list(new QueryWrapper<CardIdentityRelationInfo>()
                .eq(CardIdentityRelationInfo.COL_CARD_ID, cardInfoVo.getId()));

        List<Integer> identityIdList = cardIdentityRelationInfoList.stream().map(CardIdentityRelationInfo::getIdentityId).collect(Collectors.toList());
        List<IdentityInfo> identityInfoList = identityInfoService.list(new QueryWrapper<IdentityInfo>().in(IdentityInfo.COL_ID, identityIdList));

        cardInfoVo.setIdentityInfoList(identityInfoList);

        //判断当前人二维码是否被冻结
        OrcodeFreezeList freezeList = freezeListService.getOne(new QueryWrapper<OrcodeFreezeList>().eq(OrcodeFreezeList.COL_CODE, userInfo.getUserCode()));
        // 判断解冻时间
        if (freezeList != null){
            Date date = new Date();
            if (DateUtil.compare(date,freezeList.getUnfreezeTime()) < 0){
                cardInfoVo.setElectronicShow(0);
            }
        }

        return cardInfoVo;
    }


    /**
     * 用户领卡
     *
     * @return
     */
    @Transactional(rollbackFor = Exception.class)
    @Override
    public CardInfoVo userGetMyCard(Integer userId) {
        SysUser sysUser = LoginUtil.getUserInfo();
        //
        SysUser userInfo = sysUserService.getById(userId);
        if (userId == null) {
            throw new BusinessException(userId + "不是用户");
        }
        //判断现在的卡用户信息力是否有该用户
        CardInfoUser cardInfoUser = cardInfoUserService.getOne(new QueryWrapper<CardInfoUser>()
                .eq(CardInfoUser.COL_USER_ID, userInfo.getUserId()));

        if (cardInfoUser != null) {
            //如果已经是卡了，就直接返回
            CardInfoVo cardInfoVo = this.getCardInfoById(cardInfoUser.getCardId());
            return cardInfoVo;
        }

        //如果不是，就生成
        //根据userInfo查询身份
        Integer identityId = userInfo.getIdentityId();
        if (identityId == null) {
            throw new BusinessException(userId + ",该用户身份还未确定,不能领卡");
        }
        CardIdentityRelationInfo cardIdentityRelationInfo = cardIdentityRelationInfoService.getOne(new QueryWrapper<CardIdentityRelationInfo>()
                .eq(CardIdentityRelationInfo.COL_IDENTITY_ID, identityId));

        if (cardIdentityRelationInfo == null) {
            throw new BusinessException("该用户身份还未建立对应卡,不能领卡");
        }

        CardInfoUser newCardInfouser = new CardInfoUser();
        newCardInfouser.setCreatedBy(sysUser.getUserId().toString());
        newCardInfouser.setCreatedTime(new Date());
        newCardInfouser.setCardId(cardIdentityRelationInfo.getCardId());
        newCardInfouser.setNickName(userInfo.getNickName());
        newCardInfouser.setUserId(userInfo.getUserId().intValue());
        newCardInfouser.setUserCode(userInfo.getUserCode());
        cardInfoUserService.save(newCardInfouser);

        //领卡成功，增加埋点
        StatisticalMain statisticalMain = new StatisticalMain();
        statisticalMain.setModuleName(StatisticalMainEnums.ACTIVATION);
        statisticalMain.setModuleCode(StatisticalMainEnums.ACTIVATION);
        statisticalMainService.addBuriedPoint(statisticalMain);

        CardInfoVo cardInfoVo = this.getCardInfoById(newCardInfouser.getCardId());

        //判断当前人二维码是否被冻结
        OrcodeFreezeList freezeList = freezeListService.getOne(new QueryWrapper<OrcodeFreezeList>().eq(OrcodeFreezeList.COL_CODE, userInfo.getUserCode()));
        // 判断解冻时间
        if (freezeList != null){
            Date date = new Date();
            if (DateUtil.compare(date,freezeList.getUnfreezeTime()) < 0){
                cardInfoVo.setElectronicShow(0);
            }
        }

        return cardInfoVo;
    }
}



